﻿using Furion;
using Furion.ClayObject;
using Furion.DataEncryption;
using Furion.JsonSerialization;
using Furion.RemoteRequest.Extensions;
using Furion.Templates;
using kugoudownload;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using StackExchange.Profiling.Data;
using System.Security.Cryptography.Xml;
using System.Text;


var services = Inject.Create();
// 注册服务
services.AddRemoteRequest();
services.Build();

var versionInfo = TP.Wrapper("酷狗音乐下载器",
    "[作者] cc",
    "[版本] V1.1",
    "[时间] 2022-07-06"
    );
Console.WriteLine(versionInfo);


//程序开始
Start:

//搜索分页
int PageIndex = 1;
//关键字
var searchKeyWord = string.Empty;
//操作类型
string operationKey = string.Empty;


Console.WriteLine("输入关键词:");
searchKeyWord = Console.ReadLine()??"王心凌";

SearchNext:
var singerlist = await new KugouUtil().Search(searchKeyWord, PageIndex);

Operation:

Console.WriteLine("请输入:全部下载(A)  下一页(N)  重新搜索(S) 关闭程序(E) 单曲下载请输入序号");
string userInput= Console.ReadLine()??"1";

int writeIndex = 1;
if (userInput.Trim().ToUpper().Equals("A"))
{
    new KugouUtil().DownloadAll(singerlist);
    goto Operation;
}
else if (userInput.Trim().ToUpper().Equals("N"))
{
    PageIndex++;
    goto SearchNext;
}
else if (userInput.Trim().ToUpper().Equals("S"))
{
    goto Start;
}
else if (int.TryParse(userInput, out writeIndex))
{
    if (writeIndex > 0 && writeIndex <= singerlist.Count)
    {
        new KugouUtil().Download(singerlist[writeIndex-1]);
    }
    goto Operation;
}

Console.WriteLine("操作完成.........");